﻿package mortal.game.view.heroArena.view
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.interfaces.*;

    public class HeroArenaCreateTeamWin extends SmallWindow
    {
        private var _textInput:GTextInput;
        private var _confirmBtn:GButton;
        private var _cancelBtn:GButton;
        private static var _instance:HeroArenaCreateTeamWin;

        public function HeroArenaCreateTeamWin(param1:ILayer = null)
        {
            super(param1);
            setSize(273, 175);
            title = Language.getString(41535);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41536), 35 - 18, 65, 81, 20, this));
            this._textInput = UIFactory.gTextInput(35 + 80 - 18, 65, 180 - 10, 20, this);
            this._textInput.editable = true;
            this._confirmBtn = UIFactory.gButton(Language.getString(41537), 87, 130, 49, 22, this);
            this._cancelBtn = UIFactory.gButton(Language.getString(41538), 152, 130, 49, 22, this);
            this._confirmBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._cancelBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            if (event.target == this._confirmBtn)
            {
                if (!this._textInput.text)
                {
                    MsgManager.showRollTipsMsg(Language.getString(41539));
                    return;
                }
                GameProxy.copy.createArenaTeam(this._textInput.text);
                this.hide();
            }
            if (event.target == this._cancelBtn)
            {
                this.hide();
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._textInput.dispose();
            this._textInput = null;
            this._confirmBtn.dispose();
            this._confirmBtn = null;
            this._cancelBtn.dispose();
            this._cancelBtn = null;
            return;
        }// end function

        public static function get instance() : HeroArenaCreateTeamWin
        {
            if (_instance == null)
            {
                _instance = new HeroArenaCreateTeamWin;
            }
            return _instance;
        }// end function

    }
}
